﻿CREATE TABLE [dbo].[Order_Change] (
    [id]         INT              IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL,
    [OId]        UNIQUEIDENTIFIER NOT NULL,
    [CusId]      UNIQUEIDENTIFIER NOT NULL,
    [CusName]    NVARCHAR (200)   CONSTRAINT [DF_Order_Change_CusName] DEFAULT ('') NULL,
    [shqr]       VARCHAR (20)     CONSTRAINT [DF_Order_Change_shqr] DEFAULT ('') NOT NULL,
    [shqrxm]     NVARCHAR (30)    CONSTRAINT [DF_Order_Change_shqrxm] DEFAULT ('') NULL,
    [shqrq]      DATETIME         CONSTRAINT [DF_Order_Change_shqrq] DEFAULT (getdate()) NOT NULL,
    [bgnr]       VARCHAR (MAX)    CONSTRAINT [DF_Order_Change_bgnr] DEFAULT ('') NULL,
    [oldje]      DECIMAL (18, 2)  CONSTRAINT [DF_Order_Change_oldje] DEFAULT ((0)) NOT NULL,
    [newje]      DECIMAL (18, 2)  CONSTRAINT [DF_Order_Change_newje] DEFAULT ((0)) NOT NULL,
    [flag]       SMALLINT         CONSTRAINT [DF_Order_Change_flag] DEFAULT ((0)) NOT NULL,
    [CompanyId]  INT              CONSTRAINT [DF_Order_Change_CompanyId] DEFAULT ((0)) NOT NULL,
    [ChangeType] INT              CONSTRAINT [DF_Order_Change_ChangeType] DEFAULT ((0)) NOT NULL,
    CONSTRAINT [PK_Order_Change] PRIMARY KEY CLUSTERED ([id] ASC)
);


GO
CREATE NONCLUSTERED INDEX [IX_Order_Change_OId]
    ON [dbo].[Order_Change]([OId] ASC);


GO
CREATE NONCLUSTERED INDEX [IX_Order_Change_CompanyId]
    ON [dbo].[Order_Change]([shqr] ASC);


GO
CREATE NONCLUSTERED INDEX [IX_Order_Change_ChangeType]
    ON [dbo].[Order_Change]([ChangeType] ASC);


GO
CREATE NONCLUSTERED INDEX [IX_Order_Change_CusName]
    ON [dbo].[Order_Change]([CusName] ASC);


GO
CREATE NONCLUSTERED INDEX [IX_Order_Change_shqr]
    ON [dbo].[Order_Change]([shqr] ASC);


GO
CREATE NONCLUSTERED INDEX [IX_Order_Change_shqrq]
    ON [dbo].[Order_Change]([shqrq] ASC);


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'变更的成单ID', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Order_Change', @level2type = N'COLUMN', @level2name = N'OId';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'客户编号', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Order_Change', @level2type = N'COLUMN', @level2name = N'CusId';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'客户名称', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Order_Change', @level2type = N'COLUMN', @level2name = N'CusName';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'申请人编号', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Order_Change', @level2type = N'COLUMN', @level2name = N'shqr';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'申请人姓名', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Order_Change', @level2type = N'COLUMN', @level2name = N'shqrxm';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'变更内容', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Order_Change', @level2type = N'COLUMN', @level2name = N'bgnr';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'原成单金额', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Order_Change', @level2type = N'COLUMN', @level2name = N'oldje';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'变更进度 0等待处理 -1 不予批准 1 变更完毕', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Order_Change', @level2type = N'COLUMN', @level2name = N'flag';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'公司编号', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Order_Change', @level2type = N'COLUMN', @level2name = N'CompanyId';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'变更类型  0变更 1退单', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Order_Change', @level2type = N'COLUMN', @level2name = N'ChangeType';

